<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/include.inc.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/views/layout/base.ref.jsp" %>
    <link rel="stylesheet" href="${ctx}/static/meeting/controls/subGrid/subgrid.css"/>
</head>
<body>
<form method="post" id="form1" action="${ctx}/customsearch/select">
    <input type="hidden" name="arg" id="ids" value="${vo.arg}"/> <input type="hidden" name="code" id="code"
                                                                        value="${vo.code}"/> <input type="hidden"
                                                                                                    name="pageNum"
                                                                                                    value="${vo.pageNum}"/>
    <c:if test="${defaultParam != null }">
        <input type="hidden" name="defaultParam" value="${defaultParam}"/>
    </c:if>
    <div class="col-xs-12">
        <div class="mtrow">
            <div class="mtcolall">
                <c:forEach items="${listControl}" var="con">
                    <label class="mtlabel-auto">${con.controlName}：</label>
                    <c:choose>
                        <c:when test="${con.controlType == 0}">
                            <input type="text" class="mtinput" name="${con.fieldControl}"
                                   value="${vo[con.fieldControl]}"/>
                        </c:when>
                        <c:when test="${con.controlType == 1}">
                            <input type="text" class="mtinput" name="${con.fieldControl}"
                                   value="${vo[con.fieldControl]}"/>
                        </c:when>

                    </c:choose>
                </c:forEach>
                <a class="mtbtn search marginleft" href="#" onclick="submit_onclick()"><i class="mtfa mt-search"></i><span>查询</span></a>
            </div>
        </div>
        <div>
            <table id="grid" style="margin-top: 10px;">
            </table>
        </div>
    </div>
    <input type="hidden" name="resultcallback" id="resultcallback" value="${resultcallback}">
</form>
</body>
</html>
<script src="${ctx}/static/meeting/controls/subGrid/jquery.subgrid.js" type="text/javascript"></script>
<script type="text/javascript">
    //子表控件对象
    var SubGrid;

    var option = {
        idField: "is",
        data: "",
        columns: "",
        checkBox: false,
        select: true
    }

    function submit_onclick() {
        $("#form1").submit();
    }

    window.onload = function () {
        option.columns = ${columns};
        option.data = ${data};
        SubGrid = $("#grid").subgrid(option).data("subgrid");

    }

    function select_submit(rowIndex) {
        var data = SubGrid.getAllRows();
        var result = [{"result1": ""}, {"result2": ""}, {"result2": ""}, {"result4": ""}, {"result5": ""}, {"result6": ""}, {"result7": ""}, {"result8": ""}, {"result9": ""}, {"result10": ""}];
        var hed = ["result1", "result2", "result3", "result4", "result5", "result6", "result7", "result8", "result9", "result10"];
        if (data.length == 0) {
            layer.msg("请选择数据", {icon: 3});
        } else {
            $.each(data, function (index, rowData) {
                if (index == rowIndex) {
                    result = rowData;
                    window.parent.sysSelect_getlay(result, rowData);
                    //执行结果回调函数
                    if ($("#resultcallback").val()) {
                        eval("window.parent.${resultcallback}(rowData)");
                    }
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭   
                }
            });
        }

    }
</script>

